﻿@{
    Layout = "~/Views/Shared/_Index.cshtml";
}

<div class="container-div">
    <div class="row">
        <div class="col-sm-12 search-collapse">
            <form id="post-form">
                <div class="select-list">
                    <ul>
                        <li>
                            表名称：<input id="tableName" name="TableName" type="text" />
                        </li>
                        <li>
                            <a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i class="fa fa-search"></i>&nbsp;搜索</a>
                            <a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i class="fa fa-refresh"></i>&nbsp;重置</a>
                        </li>
                    </ul>
                </div>
            </form>
        </div>

        <div class="btn-group-sm" id="toolbar" role="group">
            <a id="btnEdit" class="btn btn-primary disabled" onclick="showGenerateForm()"><i class="fa fa-edit"></i> 生成</a>
        </div>
        <div class="col-sm-12 select-table table-striped">
            <table id="gridTable"></table>
        </div>
    </div>
</div>
<script type="text/javascript">
    $(function () {
        var options = {
            id: "gridTable",
            url: "/SystemManage/Database/GetTablePageListJson",
            createUrl: "",
            updateUrl: "",
            removeUrl: "",
            exportUrl: "",
            modalName: "任务",
            sortName: "TableName",
            sortOrder: "Asc",
            columns: [
                { checkbox: true, visible: true },
                { field: 'id', title: 'id', visible: false },
                { field: 'tableName', title: '表名称', sortable: true },
                { field: 'tableKeyName', title: '主键名称' },
                { field: 'tableKey', title: '主键字段' },
                { field: 'tableCount', title: '记录数' },
                { field: 'remark', title: '备注' }
            ],
            onClickRow: function (row, element) {
                element[0].firstElementChild.firstElementChild.click();
            }
        };
        $.table.init(options);
    });



    function showGenerateForm() {
        var tableName = '';
        var selectedRow = $("#gridTable").bootstrapTable("getSelections");
        if (!ys.checkRowEdit(selectedRow)) {
            return;
        }
        else {
            tableName = selectedRow[0].tableName;
        }

        ys.openDialog({
            title: "生成代码",
            content: '/ToolManage/CodeGenerator/CodeGeneratorForm?tableName=' + tableName,
            width: "1100px",
            height: "550px",
            btn: [],
            callback: function (index, layero) {
                var iframeWin = window[layero.find('iframe')[0]['name']];
                iframeWin.saveForm(index);
            }
        });
    }
</script>
